<!-- 云诺 https://app.witframe.com/market/list/index?uid=24 -->
<template>
	<view class="content">
		<u-navbar title="新闻资讯" :autoBack="true"></u-navbar>


		<view id="content-body" class="content-body clearfix">
			<text class="content-title">{{info.tName}}</text>
			<br />
			<view class="content-time">
				<u-row customStyle="margin-bottom: 10px">
					<u-col span="5">
						<uni-dateformat class="info-date" :date="info.wUpdateTime * 1000" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
					</u-col>
					<u-col span="1">
						<!--
						<view class="col-right"><u-icon name="eye"></u-icon></view>
						-->
					</u-col>
					<u-col span="6">
						<view class="col-right">浏览量：{{info.iViews}}</view>
					</u-col>
				</u-row>
			</view>
			<u-line length="70%"></u-line>
			<u-parse :content="info.btContent" :tag-style="tagStyle"></u-parse>
		</view>

		<yn-tabbar currentTab='news'></yn-tabbar>
	</view>
</template>

<script>
	import API from '@/common/api.js';
	var app = getApp();
	export default {
		data() {
			return {
				baseinfo: [],
				minappinfo: [],
				info: [],
				tagStyle: {
					img: 'display:block;width:100%;height:auto;',
					p: 'padding-top:20rpx',
					table: 'width:100%',
					iframe: 'width:100%',
					video: 'width:100%',
					audio: 'width:100%',
				}
			}
		},
		onLoad(options) {
			this.baseinfo = uni.getStorageSync('baseinfo');
			this.minappinfo = uni.getStorageSync('minappinfo');
			
			this.getNewsDetail({
				id: options.id
			});
		},
		onShareAppMessage: function() {
			let title = this.info.tName ? this.info.tName : (this.minappinfo.tShareName ? this.minappinfo.tShareName : '云诺服务');
			let img = this.info.tPhoto ? this.info.tPhoto : (this.minappinfo.tLogo ? this.minappinfo.tLogo : '../../images/default.png');
		
			return {
				title: title,
				imageUrl: img,
				path: '/pages/news/detail?id='+this.info._id
			}
		},
		onShareTimeline: function(res) {
			let title = this.info.tName ? this.info.tName : (this.minappinfo.tShareName ? this.minappinfo.tShareName : '云诺服务');
			let img = this.info.tPhoto ? this.info.tPhoto : (this.minappinfo.tLogo ? this.minappinfo.tLogo : '../../images/default.png');
			if (this.minappinfo.tShareDesc) {
				title = this.minappinfo.tShareName + " - " + this.minappinfo.tShareDesc
			}
			return {
				title: title,
				imageUrl: img,
				path: '/pages/news/detail?id='+this.info._id
			}
		},
		methods: {
			getNewsDetail: function(args) {
				API.getNewsDetail(args).then(res => {
						this.info = res.data.detail;
						if (this.info.tPhoto) {
							this.info.tPhoto = API.getApiUrl() + '/cos/img?key=' + this.info.tPhoto;
						} else {
							this.info.tPhoto= '/static/images/default.png';
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		margin-top: 100rpx;
	}

	.content-body {
		clear: both;
		color: #37393e;
		margin: 0;
		padding: 80rpx 30rpx;
		font-size: 36rpx;
		line-height: 70rpx;
		text-align: justify;
		word-wrap: break-word;
		word-break: normal;
		font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", SimSun, FangSong, SimHei, KaiTi, sans-serif;

		video {
			width: 100% !important;
		}

		image {
			width: 100% !important;
		}

		.content-title {
			color: #000000;
			text-indent: 10rpx;
			line-height: 50rpx;
			font-weight: 500rpx;
		}
		
		.content-time {
			color: #37393e;
			font-size: 20rpx;
		}
		.col-left{
			margin-left: 10rpx;
			float: left;
		}
		.col-right{
			float: right;
		}
	}
</style>
